﻿//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
// 此文件由工具自动生成，请勿直接修改。
// 生成时间：2024-12-30 16:18:49.458
//------------------------------------------------------------

using GameFramework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine;
using UnityGameFramework.Runtime;

namespace ProjectMG
{
    /// <summary>
    /// COMMENT。
    /// </summary>
    public class DRDataTableTemplate : DataRowBase
    {
        private int m_Id = 0;

        /// <summary>
        /// 获取数据索引。
        /// </summary>
        public override int Id
        {
            get
            {
                return m_Id;
            }
        }

        /// <summary>
        /// 获取例-string。
        /// </summary>
        public string Test_String
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-bool。
        /// </summary>
        public bool Test_Bool
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-byte。
        /// </summary>
        public byte Test_Byte
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-sbyte。
        /// </summary>
        public sbyte Test_Sbyte
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-char。
        /// </summary>
        public char Test_Char
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-decimal。
        /// </summary>
        public decimal Test_Decimal
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-DateTime。
        /// </summary>
        public DateTime Test_DateTime
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-int。
        /// </summary>
        public int Test_Int
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-short。
        /// </summary>
        public short Test_Short
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-long。
        /// </summary>
        public long Test_Long
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-uint。
        /// </summary>
        public uint Test_Uint
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-ushort。
        /// </summary>
        public ushort Test_Ushort
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-ulong。
        /// </summary>
        public ulong Test_Ulong
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-float。
        /// </summary>
        public float Test_Float
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-double。
        /// </summary>
        public double Test_Double
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-int[]。
        /// </summary>
        public int[] Test_IntArray
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-Vector3[]。
        /// </summary>
        public Vector3[] Test_Vector3Array
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-string[]。
        /// </summary>
        public string[] Test_StringArray
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-List<int>。
        /// </summary>
        public List<int> Test_IntList
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-List<Vector3>。
        /// </summary>
        public List<Vector3> Test_Vector3List
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-List<string>。
        /// </summary>
        public List<string> Test_StringList
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-Dictionary<int,int>。
        /// </summary>
        public Dictionary<int,int> Test_IntDictionary
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-Dictionary<int,Vector3>。
        /// </summary>
        public Dictionary<int,Vector3> Test_Vector3Dictionary
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-Dictionary<int,string>。
        /// </summary>
        public Dictionary<int,string> Test_StringDictionary
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-Color。
        /// </summary>
        public Color Test_Color
        {
            get;
            private set;
        }

        /// <summary>
        /// 获取例-Color32。
        /// </summary>
        public Color32 Test_Color32
        {
            get;
            private set;
        }

        public override bool ParseDataRow(string dataRowString, object userData)
        {
            string[] columnStrings = dataRowString.Split(DataTableExtension.DataSplitSeparators);
            for (int i = 0; i < columnStrings.Length; i++)
            {
                columnStrings[i] = columnStrings[i].Trim(DataTableExtension.DataTrimSeparators);
            }

            int index = 0;
            int? key = null;
            try
            {
                m_Id = int.Parse(columnStrings[index++]);
                key = m_Id;
                index++;
                Test_String = columnStrings[index++];
                Test_Bool = bool.Parse(columnStrings[index++]);
                Test_Byte = byte.Parse(columnStrings[index++]);
                Test_Sbyte = sbyte.Parse(columnStrings[index++]);
                Test_Char = char.Parse(columnStrings[index++]);
                Test_Decimal = decimal.Parse(columnStrings[index++]);
                Test_DateTime = DateTime.Parse(columnStrings[index++]);
                Test_Int = int.Parse(columnStrings[index++]);
                Test_Short = short.Parse(columnStrings[index++]);
                Test_Long = long.Parse(columnStrings[index++]);
                Test_Uint = uint.Parse(columnStrings[index++]);
                Test_Ushort = ushort.Parse(columnStrings[index++]);
                Test_Ulong = ulong.Parse(columnStrings[index++]);
                Test_Float = float.Parse(columnStrings[index++]);
                Test_Double = double.Parse(columnStrings[index++]);
                Test_IntArray = DataTableExtension.ParseArray<int>(columnStrings[index++]);
                Test_Vector3Array = DataTableExtension.ParseArray<Vector3>(columnStrings[index++]);
                Test_StringArray = DataTableExtension.ParseArray<string>(columnStrings[index++]);
                Test_IntList = DataTableExtension.ParseList<int>(columnStrings[index++]);
                Test_Vector3List = DataTableExtension.ParseList<Vector3>(columnStrings[index++]);
                Test_StringList = DataTableExtension.ParseList<string>(columnStrings[index++]);
                Test_IntDictionary = DataTableExtension.ParseDictionary<int,int>(columnStrings[index++]);
                Test_Vector3Dictionary = DataTableExtension.ParseDictionary<int,Vector3>(columnStrings[index++]);
                Test_StringDictionary = DataTableExtension.ParseDictionary<int,string>(columnStrings[index++]);
                Test_Color = DataTableExtension.ParseColor(columnStrings[index++]);
                Test_Color32 = DataTableExtension.ParseColor32(columnStrings[index++]);
                index++;
            }
            catch (Exception e)
            {
                ((DataTableHelper.ParseDataRowError)userData).Set(index, key, e);
                return false;
            }

            return true;
        }

        public override bool ParseDataRow(byte[] dataRowBytes, int startIndex, int length, object userData)
        {
            Tuple<BinaryReader, GameFrameworkFunc<int, string>> tuple = (Tuple<BinaryReader, GameFrameworkFunc<int, string>>)userData;
            BinaryReader binaryReader = tuple.Item1;
            GameFrameworkFunc<int, string> GetString = tuple.Item2;

            m_Id = binaryReader.Read7BitEncodedInt32();
            Test_String = binaryReader.ParseSystemType<string>();
            Test_Bool = binaryReader.ParseSystemType<bool>();
            Test_Byte = binaryReader.ParseSystemType<byte>();
            Test_Sbyte = binaryReader.ParseSystemType<sbyte>();
            Test_Char = binaryReader.ParseSystemType<char>();
            Test_Decimal = binaryReader.ParseSystemType<decimal>();
            Test_DateTime = binaryReader.ParseSystemType<DateTime>();
            Test_Int = binaryReader.ParseSystemType<int>();
            Test_Short = binaryReader.ParseSystemType<short>();
            Test_Long = binaryReader.ParseSystemType<long>();
            Test_Uint = binaryReader.ParseSystemType<uint>();
            Test_Ushort = binaryReader.ParseSystemType<ushort>();
            Test_Ulong = binaryReader.ParseSystemType<ulong>();
            Test_Float = binaryReader.ParseSystemType<float>();
            Test_Double = binaryReader.ParseSystemType<double>();
            Test_IntArray = binaryReader.ParseArray<int>();
            Test_Vector3Array = binaryReader.ParseArray<Vector3>();
            Test_StringArray = binaryReader.ParseArray<string>();
            Test_IntList = binaryReader.ParseList<int>();
            Test_Vector3List = binaryReader.ParseList<Vector3>();
            Test_StringList = binaryReader.ParseList<string>();
            Test_IntDictionary = binaryReader.ParseDictionary<int,int>();
            Test_Vector3Dictionary = binaryReader.ParseDictionary<int,Vector3>();
            Test_StringDictionary = binaryReader.ParseDictionary<int,string>();
            Test_Color = binaryReader.ParseSystemType<Color>();
            Test_Color32 = binaryReader.ParseSystemType<Color32>();

            return true;
        }

        public int Test_ColorCount
        {
            get
            {
                return 1;
            }
        }

        public Color32 GetTest_Color(int id)
        {
            switch (id)
            {
                case 32:
                    return Test_Color32;

                default:
                    throw new GameLogicException(Utility.Text.Format("GetTest_Color with invalid id '{0}'.", id));
            }
        }

        public Color32 GetTest_ColorAt(int index)
        {
            switch (index)
            {
                case 0:
                    return Test_Color32;

                default:
                    throw new GameLogicException(Utility.Text.Format("GetTest_ColorAt with invalid index '{0}'.", index));
            }
        }
    }
}
